#include "HttpServer.hpp"

using namespace HttpServerModule;



void Login( Request& req, Response& res)
{
    LOG(LogLevel::INFO) << "进入登录界面: _path: " << req.Path() << "参数: " << req.Args();

    res.SetCode(200);
    std::string body  = "<html><body><p>Hello,World!</p></body></html>";
    res.SetBody(body);

}
void Research(const Request& req,const Response& res) 
{
    LOG(LogLevel::INFO) << "进入搜索界面: _path: " << req.Path() << "参数: " << req.Args();
}
void Test(const Request& req,const Response& res)
{
    LOG(LogLevel::INFO) << "进入测试界面: _path: " << req.Path() << "参数: " << req.Args();
}
void Register(const Request& req,const Response& res)
{
    LOG(LogLevel::INFO) << "进入注册界面: _path: " << req.Path() << "参数: " << req.Args();
}

int main(int argc,char* argv[])
{
    ENABLE_FILESYSTEM_LOG_STRATEGY();
    if (argc != 2)
    {
        std::cout << "Use htttpserver + port!!" << std::endl;
        return 1;
    }
    std::shared_ptr<HttpServer> httpserver = std::make_shared<HttpServer>(std::stoi(argv[1]));
    httpserver->RegisterHander("/login",Login);
    httpserver->RegisterHander("/research",Research);
    httpserver->RegisterHander("/test",Test);
    httpserver->RegisterHander("/register",Register);
    httpserver->Start();
    return 0;
}